package com.rpay.dao.banner;

import com.rpay.model.banner.BannerDO;
import com.rpay.model.banner.BannerQueryDO;
import com.rpay.model.news.NewsDO;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class BannerDao {
    @Autowired
    @Qualifier("readSqlSession")
    private SqlSessionTemplate readSqlSession;

    @Autowired
    @Qualifier("writeSqlSession")
    private SqlSessionTemplate writeSqlSession;

    public List<BannerDO> list(BannerQueryDO bannerQueryDO) {
        return readSqlSession.selectList("rpay.banner.list", bannerQueryDO);
    }

    public int post(BannerDO bannerDO) {
        return writeSqlSession.insert("rpay.banner.post", bannerDO);
    }

    public int delete(Integer id) {
        return writeSqlSession.update("rpay.banner.delete", id);
    }

    public int patch(BannerDO bannerDO) {
        return writeSqlSession.update("rpay.banner.patch", bannerDO);
    }
}
